package com.ruoyi.web.controller.teaching;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.teaching.dto.ParameterIdDto;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teaching.domain.BblRepeate;
import com.ruoyi.teaching.service.IBblRepeateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 留级学生名单Controller
 * lbj
 * @author ruoyi
 * @date 2023-05-19
 */
@RestController
@RequestMapping("/teaching/repeate")
public class BblRepeateController extends BaseController
{
    @Autowired
    private IBblRepeateService bblRepeateService;

    /**
     * 查询留级学生名单列表
     */
    @PreAuthorize("@ss.hasPermi('teaching:repeate:list')")
    @GetMapping("/list")
    public TableDataInfo list(BblRepeate bblRepeate)
    {
        startPage();
        List<BblRepeate> list = bblRepeateService.selectBblRepeateList(bblRepeate);
        return getDataTable(list);
    }

    /**
     * 导出留级学生名单列表
     */
    @PreAuthorize("@ss.hasPermi('teaching:repeate:export')")
    @Log(title = "留级学生名单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BblRepeate bblRepeate)
    {
        List<BblRepeate> list = bblRepeateService.selectBblRepeateList(bblRepeate);
        ExcelUtil<BblRepeate> util = new ExcelUtil<BblRepeate>(BblRepeate.class);
        util.exportExcel(response, list, "留级学生名单数据");
    }

    /**
     * 获取留级学生名单详细信息
     */
    @PreAuthorize("@ss.hasPermi('teaching:repeate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bblRepeateService.selectBblRepeateById(id));
    }

    /**
     * 新增留级学生名单
     */
    @PreAuthorize("@ss.hasPermi('teaching:repeate:add')")
    @Log(title = "留级学生名单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BblRepeate bblRepeate)
    {
        System.out.println(bblRepeate);
        return toAjax(bblRepeateService.insertBblRepeate(bblRepeate));
    }

    /**
     * 修改留级学生名单
     */
    @PreAuthorize("@ss.hasPermi('teaching:repeate:edit')")
    @Log(title = "留级学生名单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BblRepeate bblRepeate)
    {
        return toAjax(bblRepeateService.updateBblRepeate(bblRepeate));
    }

    /**
     * 删除留级学生名单
     */
    @PreAuthorize("@ss.hasPermi('teaching:repeate:remove')")
    @Log(title = "留级学生名单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bblRepeateService.deleteBblRepeateByIds(ids));
    }

    /**
     * 获取留级学生名单详细信息
     */
    @PreAuthorize("@ss.hasPermi('teaching:repeate:query')")
    @PostMapping("/getparems")
    public AjaxResult addTaskData(@RequestBody ParameterIdDto parameter)
    {
        System.out.println(parameter);
        return toAjax(bblRepeateService.addTaskData(parameter));
    }
}
